home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / talinasm.lha / unionrect.asm < prev    next >
Encoding:
Assembly Source File  |  1992-03-19  |  1.3 KB  |  57 lines

  1. * ============================================================================ *
  2. *    UnionRect: Calculate a rectangle which surround two others
  3. *
  4. *    struct IBox *UnionRect(struct IBox *a, struct IBox *b, struct IBox *result);
  5. *                              a0              a1                   a2
  6. * ============================================================================ *
  7.  
  8.             include        'intuition/intuition.i'
  9.  
  10.             SECTION        unionrect.asm,CODE
  11.  
  12.             xdef        _UnionRect
  13. _UnionRect:            ; (a0, a1, a2)
  14.  
  15. ;    x1 = MIN(a->Left, b->Left);
  16.  
  17.             move.w        ibox_Left(a0),d0
  18.             move.w        ibox_Left(a1),d1
  19.             move.w        d0,ibox_Left(a2)
  20.             cmp.w        d0,d1
  21.             bgt.s        1$
  22.             move.w        d1,ibox_Left(a2)
  23. 1$
  24.  
  25. ;    x2 = MAX(a->Left + a->Width, b->Left + b->Width) - x1;
  26.  
  27.             add.w        ibox_Width(a0),d0
  28.             add.w        ibox_Width(a1),d1
  29.             cmp.w        d0,d1
  30.             blt.s        2$
  31.             move.w        d1,d0
  32. 2$            sub.w        ibox_Left(a2),d0
  33.             move.w        d0,ibox_Width(a2)
  34.  
  35. ;    y1 = MIN(a->Top, b->Top);
  36.  
  37.             move.w        ibox_Top(a0),d0
  38.             move.w        ibox_Top(a1),d1
  39.             move.w        d0,ibox_Top(a2)
  40.             cmp.w        d0,d1
  41.             bgt.s        3$
  42.             move.w        d1,ibox_Top(a2)
  43. 3$
  44. ;    y2 = MAX(a->Top + a->Height, b->Top + b->Height) - y1;
  45.  
  46.             add.w        ibox_Height(a0),d0
  47.             add.w        ibox_Height(a1),d1
  48.             cmp.w        d0,d1
  49.             blt.s        4$
  50.             move.w        d1,d0
  51. 4$            sub.w        ibox_Top(a2),d0
  52.             move.w        d0,ibox_Height(a2)
  53.             
  54.             move.l        a2,d0                    ; return address of result
  55.  
  56.             rts
  57.